import org.apache.log4j.ConsoleAppender
import org.apache.log4j.DailyRollingFileAppender
import org.apache.log4j.PatternLayout
import org.apache.log4j.Priority

// locations to search for config files that get merged into the main config;
// config files can be ConfigSlurper scripts, Java properties files, or classes
// in the classpath in ConfigSlurper format

// grails.config.locations = [ "classpath:${appName}-config.properties",
//                             "classpath:${appName}-config.groovy",
//                             "file:${userHome}/.grails/${appName}-config.properties",
//                             "file:${userHome}/.grails/${appName}-config.groovy"]

// if (System.properties["${appName}.config.location"]) {
//    grails.config.locations << "file:" + System.properties["${appName}.config.location"]
// }

grails.project.groupId = appName // change this to alter the default package name and Maven publishing destination

// The ACCEPT header will not be used for content negotiation for user agents containing the following strings (defaults to the 4 major rendering engines)
grails.mime.disable.accept.header.userAgents = ['Gecko', 'WebKit', 'Presto', 'Trident']
grails.mime.types = [
        all: '*/*',
        atom: 'application/atom+xml',
        css: 'text/css',
        csv: 'text/csv',
        form: 'application/x-www-form-urlencoded',
        html: ['text/html', 'application/xhtml+xml'],
        js: 'text/javascript',
        json: ['application/json', 'text/json'],
        multipartForm: 'multipart/form-data',
        rss: 'application/rss+xml',
        text: 'text/plain',
        hal: ['application/hal+json', 'application/hal+xml'],
        xml: ['text/xml', 'application/xml']
]

// URL Mapping Cache Max Size, defaults to 5000
//grails.urlmapping.cache.maxsize = 1000

// What URL patterns should be processed by the resources plugin
grails.resources.adhoc.patterns = ['/images/*', '/css/*', '/js/*', '/plugins/*']

// Legacy setting for codec used to encode data with ${}
grails.views.default.codec = "html"

// The default scope for controllers. May be prototype, session or singleton.
// If unspecified, controllers are prototype scoped.
grails.controllers.defaultScope = 'singleton'

// GSP settings
grails {
    views {
        gsp {
            encoding = 'UTF-8'
            htmlcodec = 'xml' // use xml escaping instead of HTML4 escaping
            codecs {
                expression = 'html' // escapes values inside ${}
                scriptlet = 'html' // escapes output from scriptlets in GSPs
                taglib = 'none' // escapes output from taglibs
                staticparts = 'none' // escapes output from static template parts
            }
        }
        // escapes all not-encoded output at final stage of outputting
        filteringCodecForContentType {
            //'text/html' = 'html'
        }
    }
}

grails.converters.encoding = "UTF-8"
// scaffolding templates configuration
grails.scaffolding.templates.domainSuffix = 'Instance'

// Set to false to use the new Grails 1.2 JSONBuilder in the render method
grails.json.legacy.builder = false
// enabled native2ascii conversion of i18n properties files
grails.enable.native2ascii = true
// packages to include in Spring bean scanning
grails.spring.bean.packages = []
// whether to disable processing of multi part requests
grails.web.disable.multipart = false

// request parameters to mask when logging exceptions
grails.exceptionresolver.params.exclude = ['password']

// configure auto-caching of queries by default (if false you can cache individual queries with 'cache: true')
grails.hibernate.cache.queries = false

grails.zthz.train.SmsCodeTime = 60 * 15 //sms有效期默认15分钟

/*
environments {
    development {
        grails.logging.jul.usebridge = true
    }
    production {
        grails.logging.jul.usebridge = false
    }
    test{
        grails.logging.jul.usebridge = true
    }
}
*/

// log4j configuration
log4j = {
    // Example of changing the log pattern for the default console appender:
    //
    def log4jBaseName = "${System.properties.getProperty('catalina.base', '.')}/logs/"
    def logLayoutPattern = new PatternLayout("%d [%t] %-5p %c %x - %m%n")
    def log4jAppFileLogLevel = Priority.DEBUG
    def log4jConsoleLogLevel = Priority.DEBUG

    appenders {
        appender new ConsoleAppender(name: "console",
                threshold: log4jConsoleLogLevel,
                layout: logLayoutPattern
        )
        appender new DailyRollingFileAppender(name: "douxing",
                threshold: log4jAppFileLogLevel,
                file: "${log4jBaseName}douxing.log",
                datePattern: "'.'yyyy-MM-dd-HH",
                layout: logLayoutPattern
        )
        appender new DailyRollingFileAppender(name: "stacktrace",
                threshold: log4jAppFileLogLevel,
                file: "${log4jBaseName}stacktrace.log",
                datePattern: "'.'yyyy-MM-dd-HH",
                layout: logLayoutPattern
        )
    }

    root {
        info 'console', 'douxing'
    }


    debug  douxing: ['grails.app.controllers.com.zthz',
            'grails.app.jobs.com.zthz',
            'grails.app.jobs',
            'org.hibernate.sql',
            'com.zhtz' ]

    error  stacktrace: ['org.codehaus.groovy.grails.web.servlet',        // controllers
            'org.codehaus.groovy.grails.web.pages',          // GSP
            'org.codehaus.groovy.grails.web.sitemesh',       // layouts
            'org.codehaus.groovy.grails.web.mapping.filter', // URL mapping
            'org.codehaus.groovy.grails.web.mapping',        // URL mapping
            'org.codehaus.groovy.grails.commons',            // core / classloading
            'org.codehaus.groovy.grails.plugins',            // plugins
            'org.codehaus.groovy.grails.orm.hibernate',      // hibernate integration
            'org.springframework',
            'org.hibernate',
            "org.quartz.core",
            "grails.plugin",
            "org.codehaus.groovy",
            "org.apache.naming",
            'net.sf.ehcache.hibernate',
            'grails.plugins'
    ]

    /*
    appenders {
        appender new ConsoleAppender(name: "console",
                threshold: log4jConsoleLogLevel,
                layout: logLayoutPattern
        )
        appender new DailyRollingFileAppender(name: "douxing",
                threshold: log4jAppFileLogLevel,
                file: "${log4jBaseName}dxing.log",
                datePattern: "'.'yyyy-MM-dd-HH",
                layout: logLayoutPattern
        )

    }


    info 'grails.app.controllers'

    //'org.codehaus.groovy.grails.plugins.spring.security',


    */
}

grails.plugin.springsecurity.userLookup.userDomainClassName = 'com.zthz.douxing.Person'
grails.plugin.springsecurity.userLookup.authorityJoinClassName = 'com.zthz.douxing.PersonAuthority'
grails.plugin.springsecurity.authority.className = 'com.zthz.douxing.Authority'
grails.plugin.springsecurity.requestMap.className = 'com.zthz.douxing.Requestmap'
grails.plugin.springsecurity.password.algorithm = 'MD5'
grails.plugin.springsecurity.logout.afterLogoutUrl = '/douXingRegister/logout'

grails.plugin.springsecurity.successHandler.ajaxSuccessUrl = '/douXingRegister/loginSuccess'
grails.plugin.springsecurity.successHandler.defaultTargetUrl = '/'
grails.plugin.springsecurity.successHandler.alwaysUseDefault = false
//grails.plugin.springsecurity.successHandler.targetUrlParameter= SpringSecurityUtils.DEFAULT_TARGET_PARAMETER
grails.plugin.springsecurity.successHandler.useReferer = false


grails.plugin.springsecurity.failureHandler.ajaxAuthFailUrl = "/douXingRegister/loginFaile"

grails.plugin.springsecurity.rememberMe.persistent = true
grails.plugin.springsecurity.rememberMe.persistentToken.domainClassName = 'com.zthz.douxing.PersistentLogin'

/*grails.plugins.springsecurity.successHandler{
    defaultTargetUrl = '/'
    alwaysUseDefault = false
    targetUrlParameter = SpringSecurityUtils.DEFAULT_TARGET_PARAMETER // 'spring-security-redirect'
    ajaxSuccessUrl = '/douXingRegister/login'
    useReferer = false
}*/


/*
grails.plugin.springsecurity.oauthProvider.clients = [
        [
                clientId: "1",
                clientSecret: "secret"
        ]
]
*/

grails.plugin.springsecurity.controllerAnnotations.staticRules = [
        '/': ['permitAll'],
        '/**': ['permitAll'],
        '/index': ['permitAll'],
        '/index.gsp': ['permitAll'],
        '/**/js/**': ['permitAll'],
        '/**/css/**': ['permitAll'],
        '/**/images/**': ['permitAll'],
        '/**/favicon.ico': ['permitAll'],
        '/oauth/authorize.dispatch': ['IS_AUTHENTICATED_REMEMBERED'],
        '/oauth/token.dispatch': ['IS_AUTHENTICATED_REMEMBERED'],
]

//发送邮件相关
grails.plugin.springsecurity.ui.register.emailFrom = "puergeng@163.com"
grails {
    mail {
        host = "smtp.163.com"
        port = 465
        username = "puergeng@163.com"
        password = "MissPuer2"
        props = ["mail.smtp.auth": "true",
                "mail.smtp.socketFactory.port": "465",
                "mail.smtp.socketFactory.class": "javax.net.ssl.SSLSocketFactory",
                "mail.smtp.socketFactory.fallback": "false",
        ]

    }
}

//oauth相关内容

oauth {
    debug = true
    providers {
        weibo {
            api = org.scribe.builder.api.SinaWeiboApi20
            key = '1549129665'
            secret = '5e3c4c7fd76b1e01bf4287dc9a422a77'
            successUri = '/oauth/weibo/success'
            failureUri = '/oauth/weibo/error'
            callback = "${baseURL}/oauth/weibo/callback"
            scope = 'all'
        }


    }
}

/*
oauth {
    providers {
        weibo {
            api = org.scribe.builder.api.SinaWeiboApi20
            key = 'oauth_weibo_key'
            secret = 'oauth_weibo_secret'
            callback = "${baseURL}/oauth/weibo/callback"
            scope = 'all'
        }
    }
}
*/

data {
    /*
    Cron表达式的含义
   cronExpression: "s m h D M W Y"
                    | | | | | | `- Year [optional]
                    | | | | | `- Day of Week, 1-7 or SUN-SAT, ?
                    | | | | `- Month, 1-12 or JAN-DEC
                    | | | `- Day of Month, 1-31, ?6
                    | | `- Hour, 0-23
                    | `- Minute, 0-59
                    `- Second, 0-59
     */
    WeathFetchJob {
        cronExpress = "0 0 6/2 * * ?"
        handler = ['fetchDataRedisSaveService']
        expiredTime = 12 * 60 * 60
    }

    PM25FetchJob {
        cronExpress = "0 0 6/2 * * ?"
        handler = ['fetchDataRedisSaveService']
        expiredTime = 12 * 60 * 60
    }

    K780WeathFetchJob {
        cronExpress = "*/10 * * * * ?"
        //"0 0 6/2 * * ?"
        Secret = "14ad3332cde2e183a9c5436e6af0f637"
        Sign = "fd4208b1d8cfd2091bfac2dcf591e29e"
        appkey = "10812"
        handler = ['k780WeathService', 'weathPmCabinService', 'fetchDataRedisSaveService']
        expiredTime = 12 * 60 * 60 //12 个小时
        timeBatchCount = 200
    }

    MessageSendJob {
        handler = ['tripSegeMentHandlerService', 'weatherHandlerService', 'messageSendService']
    }

    MessageSend4XingeJob {//行程消息推送相关处理类
        planform = 'geTuiMessageSenderService'
        handlers = ['weatherMessageHanlderService',
                'planTripMessageBefore3HoursHanlderService',
                'planTripMessageArriveStatusHanlderService',
                'planTripMessageBeginStatusHanlderService'
        ]
    }

}


environments {
    development {
        grails {
            redis {
                poolConfig {
                    // jedis pool specific tweaks here, see jedis docs & src
                    // ex: testWhileIdle = true
                }
                timeout = 2000 //default in milliseconds
                //password = "redis_password" //defaults to no password
                // requires either host & port combo, or a sentinels and masterName combo

                // use a single redis server (use only if nore using sentinel cluster)
                port = 6379 // port
                host = "localhost"
//                host = "192.168.1.189"

            }
        }
        xingge {
            android {
                accessId = 2100019696
                secretKey = '39456ccc90d4e50241c07a50342e67ee'
            }
            ios {
                accessId = 2200019697
                secretKey = '10d776fc129f04eebffc8f64f375da8b'
            }
        }
        getui {
            android {
                APPID = 'SFc2urgIDHAuZ9Sz1cGPN8'
                APPKEY = 'WLjy38nQJaAzjverOSRVI8'
                MASTERSECRET = 'bGEJmQ9PLJ6ya4ikyWbrr2'
            }
        }
    }

    test {
        redis {
            poolConfig {
                // jedis pool specific tweaks here, see jedis docs & src
                // ex: testWhileIdle = true
            }
            timeout = 2000 //default in milliseconds
            //password = "redis_password" //defaults to no password
            // requires either host & port combo, or a sentinels and masterName combo

            // use a single redis server (use only if nore using sentinel cluster)
            port = 6379 // port
            host = "192.168.1.189"

        }
        xingge {
            android {
                accessId = 2100019696
                secretKey = '39456ccc90d4e50241c07a50342e67ee'
            }
            ios {
                accessId = 2200019697
                secretKey = '10d776fc129f04eebffc8f64f375da8b'
            }
        }
        getui{
            android{
                APPID='SFc2urgIDHAuZ9Sz1cGPN8'
                APPKEY='WLjy38nQJaAzjverOSRVI8'
                MASTERSECRET='bGEJmQ9PLJ6ya4ikyWbrr2'
            }
        }
    }


    production {
        grails {
            redis {
                poolConfig {
                    // jedis pool specific tweaks here, see jedis docs & src
                    // ex: testWhileIdle = true
                }
                timeout = 2000 //default in milliseconds
                //password = "redis_password" //defaults to no password

                // requires either host & port combo, or a sentinels and masterName combo

                // use a single redis server (use only if nore using sentinel cluster)
                port = 6379 // port
//                host = "10.171.16.81"
                host="192.168.1.189"
            }
        }
        xingge {
            android {
                accessId = 2100017402
                secretKey = '5efeebfc558299b2ca4a7d309845d9ab'
            }
            ios {
                accessId = 2200017403
                secretKey = 'b506dfda5424cce61c0a256135f4846f'
            }
        }

        getui {
            android {
                APPID = 'SFc2urgIDHAuZ9Sz1cGPN8'
                APPKEY = 'WLjy38nQJaAzjverOSRVI8'
                MASTERSECRET = 'bGEJmQ9PLJ6ya4ikyWbrr2'
            }
        }
    }
}
// Added by the Spring Security OAuth plugin:
grails.plugin.springsecurity.oauth.domainClass = 'com.zthz.douxing.OAuthID'

